package com.jp.knowledge.adapter;

import android.content.Context;
import android.widget.TextView;

import com.jp.knowledge.R;
import com.jp.knowledge.model.WalletList;
import com.jp.knowledge.util.TimeUtil;

import java.util.List;

/**
 * Created by jiayen on 17/3/22.
 *
 * 钱包实体类
 */

public class WallertAdapter extends  JpBaseRecyViewAdapter {
    public WallertAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    public int getLayoutId() {
        return R.layout.wallet_list_layout_item;
    }

    @Override
    public void bindViewHold(JPRecycleViewHolder holder, int position) {
        WalletList  walletList = (WalletList) getItem(position);
        if(walletList!=null) {
            TextView titleView = holder.getView(R.id.title);
            TextView timeView = holder.getView(R.id.time);
            TextView amountView = holder.getView(R.id.amount);

            titleView.setText(walletList.getTitle());


            timeView.setText(TimeUtil.formatData(walletList.getTime()));

            int type = walletList.getType();
            double  amount = walletList.getAmount()/100d;
            if(walletList.isShowGetamount()){
                amountView.setText("+"+amount);
                amountView.setTextColor(mContext.getResources().getColor(R.color.font_black));
            }else{
                amountView.setText("-"+amount);
                amountView.setTextColor(mContext.getResources().getColor(R.color.red));
            }

        }

    }
}
